package com.guapi.exception;

public class SelfException extends RuntimeException{

    private String code;
    private String message;
    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    @Override
    public String getMessage() {
        return message==null?super.getMessage():message;
    }

    public void setMessage(String message) {
        this.message = message;
    }


    /**
     *
     * @param code 状态码
     * @param message 报错信息
     */
    public SelfException(String code, String message) {
        super(message);
        this.message=message;
        this.code = code;
    }

    public SelfException() {
        super();
    }

    public SelfException(String message) {
        super(message);
    }

    /**
     *
     * @param code 报错信息
     * @param cause 原有异常
     */
    public SelfException(String code, Throwable cause) {
        super(cause);
        this.message=cause.getMessage();
        this.code = code;
    }

    public SelfException(Throwable cause) {
        super(cause.getMessage());
    }

    protected SelfException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
        super(message, cause, enableSuppression, writableStackTrace);
    }
}
